﻿#pragma once
#include "MaskBase.h"
#include "TubeFocus.h"
#include "PmaskChangeComponent.h"
#include "MetaCoup.h"

#include <opencv2/opencv.hpp>
#include <memory>
#include <assert.h>

class MaskBase;
class TubeFocus;
class PmaskChangeComponent;
class Opencv
{
public:
	Opencv();
	~Opencv();

	cv::Point2f Opencv_getMaskCenter(MaskBase* base, cv::Mat& mat); // 返回图的中心位置
	int Opencv_preprocess(MaskBase* base, cv::Mat& mat, Attribute& attr); //对采集到的图像进行预处理）
	void Opencv_setMaskGrayToRGB(MaskBase* base, cv::Mat& mat); //将图像从灰度转成RGB，为上色（画轮廓）准备
	int Opencv_findMaxOutline(MaskBase* base, cv::Mat& mat); //寻找图中最大的轮廓（接口已经废弃）
	int Opencv_findMaxOutline(MaskBase* base, cv::Mat& mat, Attribute& attr); //寻找图中满足条件的轮廓
	int Opencv_draw(MaskBase* base, cv::Mat& mat, Attribute& attr); //进行拟合并绘画轮廓
	cv::Point2f Opencv_getMaxOutlineCenter(MaskBase* base, Attribute& attr) const; //获取目标轮廓的中心位置
	int Opencv_drawCross(MaskBase* base, cv::Mat& mat, cv::Point2f center, const size_t crosslen); // 在指定位置画十字中心
	double Opencv_CalculatePTOPDistance(MaskBase* base, cv::Point2f center1); //计算轮廓中心与指定位置的距离
	double Opencv_CalculatePTOPDistance(MaskBase* base, cv::Point2f center1, cv::Point2f center2); //计算指定位置与指定位置的距离
	bool Opencv_isCover(MaskBase* base, double distance, const double threshold); //判断计算出的距离是否在给定的阈值范围之内
	cv::Point2f* Opencv_getTwoRoundholeCenter(MaskBase* base, cv::Mat& mat, Attribute& attr); //获取两个圆孔的中心位置

};

